﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SosaAnalysisModule.Data;
using SosaAnalysisModule;
using System.IO;

namespace SosaAnalysisModuleTest
{
    [TestClass]
    public class AnalysisModuleUnitTest : AnalysisModule
    {
        [TestMethod]
        public void NumOfMovesTest()
        {
            String path = Directory.GetCurrentDirectory();
            string token = "SosaAnalysisModule\\";
            int length = path.IndexOf(token) + token.Length;
            path = path.Substring(0, length - 1) + "SosaAnalysisModuleTest\\testFinal.csv";
            SosaData data = SOSAFileReader.CreateSosaData(path);

            StimuliPresentation sp = data.PresentationOrder[0];
            
            int sample = NumOfMoves(data.SubjectActions, sp);

            Assert.AreEqual(4,sample);
        }
        [TestMethod]
        public void ElapsedTimeTest()
        {
            String path = Directory.GetCurrentDirectory();
            string token = "SosaAnalysisModule\\";
            int length = path.IndexOf(token) + token.Length;
            path = path.Substring(0, length - 1) + "SosaAnalysisModuleTest\\testFinal.csv";
            SosaData data = SOSAFileReader.CreateSosaData(path);

            string sample = AnalysisModule.ElapsedTime(data.SubjectActions);
            Assert.AreEqual("00:00:34.7720000", sample);
        }
        [TestMethod]
        public void DistanceAnalysisTest()
        {
            String path = Directory.GetCurrentDirectory();
            string token = "SosaAnalysisModule\\";
            int length = path.IndexOf(token) + token.Length;
            path = path.Substring(0, length - 1) + "SosaAnalysisModuleTest\\testFinal.csv";
            SosaData data = SOSAFileReader.CreateSosaData(path);

            DistanceStat ds = AnalysisModule.DistanceAnalysis(data.Distances);

            Assert.AreEqual(7.862925, ds.min);
            Assert.AreEqual(20.848635, ds.max);
            Assert.AreEqual(14.876977666666669, ds.avg);
        }
    }
}
